﻿using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Configuration;
using System.ComponentModel;
using System.Collections.Generic;

namespace GreatB2C.Config.SiteInfo
{
    public class EmailConfig
    {
        #region 邮件参数配置
        /// <summary>
        /// 发送人邮箱
        /// </summary>
        public static string MailFrom
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "MailFrom" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "MailFrom" , value );
            }
        }

        /// <summary>
        /// 自动配置邮件服务器信息
        /// </summary>
        public static string CollocateCheckBox
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "CollocateCheckBox" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "CollocateCheckBox" , value );
            }
        }

        /// <summary>
        /// 发送邮件服务器
        /// </summary>
        public static string MailServer
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "MailServer" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "MailServer" , value );
            }
        }

        /// <summary>
        /// 端口号
        /// </summary>
        public static string Port
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "Port" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "Port" , value );
            }
        }

        /// <summary>
        /// 此服务器要求安全连接(SSL)
        /// </summary>
        public static string SSL
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "SSL" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "SSL" , value );
            }
        }

        /// <summary>
        /// 身份验证
        /// </summary>
        public static string Credential
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "Credential" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "Credential" , value );
            }
        }

        /// <summary>
        /// 邮箱用户名
        /// </summary>
        public static string MailUserName
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "MailUserName" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "MailUserName" , value );
            }
        }

        /// <summary>
        /// 邮箱密码
        /// </summary>
        public static string MailPassword
        {
            get
            {
                return BaseConfig.GetConfigValue( BaseConfig.eConfigs.Email , "MailPassword" );
            }
            set
            {
                BaseConfig.SetConfigValue( BaseConfig.eConfigs.Email , "MailPassword" , value );
            }
        }

        public static bool Config( string MailFrom , string CollocateCheckBox , string MailServer , string Port
            , string SSL , string Credential , string MailUserName , string MailPassword )
        {
            Dictionary<string , string> dicts = new Dictionary<string , string>( );

            dicts.Add( "MailFrom" , MailFrom );
            dicts.Add( "CollocateCheckBox" , CollocateCheckBox );
            dicts.Add( "MailServer" , MailServer );
            dicts.Add( "Port" , Port );
            dicts.Add( "SSL" , SSL );
            dicts.Add( "Credential" , Credential );
            dicts.Add( "MailUserName" , MailUserName );
            dicts.Add( "MailPassword" , MailPassword );

            return BaseConfig.SetConfigForBatch( BaseConfig.eConfigs.Email , dicts );
        }
        #endregion
    }
}
